package com.xxx.sr;

import java.io.*;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/7/22 16:01
 * @Copyright 博为峰
 */
public class SystemDemo {
    public static void main(String[] args) {
//        m1();
//        m2();
//        m3();
        //字符流=字节流+编码表
        try (FileWriter fileWriter = new FileWriter("gbk.txt")) {
            fileWriter.write("疫苗");
        } catch (IOException e) {

        }
//        FileWriter fileWriter = new FileWriter("gbk.txt")
//        try (OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream("./IO/gbk2.txt"), "GBK")) {
//            outputStreamWriter.write("核酸");
//        } catch (IOException e) {
//
//        }


    }

    public static void m3() {
        try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("./IO/bf.txt"))) {
            String str = null;
            while ((str = bufferedReader.readLine()) != null) {
                bufferedWriter.write(str);
                bufferedWriter.newLine();
                bufferedWriter.flush();
            }
        } catch (IOException e) {

        }
    }

    public static void m2() {
        try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(System.out))) {
            String str = null;
            while ((str = bufferedReader.readLine()) != null) {
                bufferedWriter.write(str);
                bufferedWriter.newLine();
                bufferedWriter.flush();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void m1() throws IOException {
        //标准输入流
        InputStream inputStream = System.in;
        //桥梁流
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
        //字符输入流
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        //标准输出流
        PrintStream out = System.out;
        //桥梁流
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(out);
        //字符输出流
        BufferedWriter bufferedWriter = new BufferedWriter(outputStreamWriter);
        String str = null;
        while ((str = bufferedReader.readLine()) != null) {
//            System.out.println(str);
            bufferedWriter.write(str);
            bufferedWriter.newLine();
            bufferedWriter.flush();
        }
    }

    /*
      1.接收用户输入的数据并写入文件中
      2.接收用户输入的学生信息保存到集合中
     */
}
